<template>
  <div style="width: 100%; height: 100%;">
      <div style="width: 100%; height: 500px;margin-left: 10px;" ref="mychart" ></div>
  </div>
</template>

<script>
//  数据可视化
  import * as echarts from 'echarts';
export default {
    props:{
        dataPie:null,
    },
    data(){
        return {
            option : {
        title: {
            text: '各景点销售额占比',
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left'
        },
        series: [
            {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: [
                { value: 1048, name: 'Search Engine' },
                { value: 735, name: 'Direct' },
                { value: 580, name: 'Email' },
                { value: 484, name: 'Union Ads' },
                { value: 300, name: 'Video Ads' }
            ],
            emphasis: {
                itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
            }
  ]
}
        }
    },
    mounted(){
        this.init(this.dataPie)
    },
    watch:{
        'dataPie':function(val){
             this.init(val)
          }
    },
    methods:{
        init(data){
          var mychart = echarts.init(this.$refs.mychart)
            //发起请求
            this.option.series[0].data = data
            mychart.setOption(this.option)
        }
    },
}
</script>

<style>

</style>